package com.ccl.iot.controler;import android.content.Context;

import com.ccl.iot.device.IOTComplexDevice;
import com.ccl.iot.device.IOTDevice;
import com.ccl.iot.device.IOTDoor;
import com.ccl.iot.device.IOTSwitch;
import com.ccl.iot.views.StandardAdapter;

public abstract class DeviceAdapter extends StandardAdapter<IOTDevice> {
	public static final int KDEVICE_TYPE_UNKNOWN = 0;
	public static final int KDEVICE_TYPE_SWITCH = 1;
	public static final int KDEVICE_TYPE_DOOR = 2;
	public static final int KDEVICE_TYPE_COMPLEX = 3;

	public DeviceAdapter(Context aContext){
		super(aContext);
	}
	
	@Override
	public int getViewTypeCount() {
		return 4;
	}
	
	@Override
	public int getItemViewType(int position) {
		IOTDevice tDevice = getItem(position);
		
		if (tDevice != null){
			if (tDevice instanceof IOTSwitch){
				return KDEVICE_TYPE_SWITCH;
			}else if (tDevice instanceof IOTDoor){
				return KDEVICE_TYPE_DOOR;
			}else if (tDevice instanceof IOTComplexDevice){
				return KDEVICE_TYPE_COMPLEX;
			}
		}
		
		return KDEVICE_TYPE_UNKNOWN;
	}
}
